{include file='_header'}
<script type="text/javascript" src="__STATIC__/js/dist/area/cascade.js"></script>
<script type="text/javascript" src="__STATIC__/js/lib/moment.js"></script>
<link rel="stylesheet" href="__STATIC__/components/datetimepicker/jquery.datetimepicker.css">
<link rel="stylesheet" href="__STATIC__/components/daterangepicker/daterangepicker.css">
<style type='text/css'>
    .trhead td {  background:#efefef;text-align: center}
    .trbody td {  text-align: center; vertical-align:top;border-left:1px solid #f2f2f2;overflow: hidden; font-size:12px;}
    .trorder { background:#f8f8f8;border:1px solid #f2f2f2;text-align:left;}
    .ops { border-right:1px solid #f2f2f2; text-align: center;}
    .ops a,.ops span{
        margin: 3px 0;
    }
    .table-top .op:hover{
        color: #000;
    }
    .tables{
        border:1px solid #e5e5e5;
        font-size: 12px;
        line-height: 18px;
    }
    .tables:hover{
        border:1px solid #b1d8f5;
    }
    .table-row,.table-header,.table-footer,.table-top{
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        justify-content: center;
        -webkit-justify-content: center;
        -webkit-align-content: space-around;
        align-content: space-around;
    }
    .tables  .table-row>div{
        padding: 14px 0 !important;
    }
    .tables  .table-row.table-top>div{
        padding: 11px 0;
    }
    .tables    .table-row .ops.list-inner{
        border-right:none;
    }
    .tables .list-inner{
       border-right: 1px solid #efefef;
        vertical-align: middle;
    }
    .table-row .goods-des .title{
        width:180px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .table-row .goods-des{
        width:300px;
        border-right: 1px solid #efefef;
        vertical-align: middle;
    }
    .table-row .list-inner{
        -webkit-box-flex: 1;
        -webkit-flex: 1;
        -ms-flex: 1;
        flex: 1;
        text-align: center;
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        -webkit-align-items: center;
        align-items: center;
        -webkit-justify-content: center;
        justify-content: center;
        -webkit-flex-direction: column;
        flex-direction: column;
    }
    .saler>div{
        width:130px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .table-row .list-inner.ops,  .table-row .list-inner.paystyle{
        -webkit-flex-direction: column;
        flex-direction: column;
       -webkit-justify-content: center;
       justify-content: center;
    }
    .table-header .others{
        -webkit-box-flex: 1;
        -webkit-flex: 1;
        -ms-flex: 1;
        flex: 1;
        text-align: center;
    }
    .table-footer{
        border-top: 1px solid #efefef;
    }
    .table-footer>div, .table-top>div{
        -webkit-box-flex: 1;
        -webkit-flex: 1;
        -ms-flex: 1;
        flex: 1;
        height:100%;
    }
    .fixed-header div{
        padding:0;
    }
    .fixed-header.table-header{
        display: none;
    }
    .fixed-header.table-header.active{
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
    }
    .shop{
        display: inline-block;
        width:48px;
        height:18px;
        text-align: center;
        border:1px solid #1b86ff;
        color: #1b86ff;
        margin-right: 10px;
    }
    .min_program{
        display: inline-block;
        width:48px;
        height:18px;
        text-align: center;
        border:1px solid #ff5555;
        color: #ff5555;
        margin-right: 10px;
    }
</style>

<div class="page-header">
    当前位置：<span class="text-primary">订单管理</span>
    <span>订单数:  <span class='text-danger'>{$total}</span> 订单金额:  <span class='text-danger'>{$totalmoney}</span> </span>
</div>
<div class="page-content">
    <div class="fixed-header table-header" style="padding: 0 50px;">
        <div style='border-left:1px solid #f2f2f2;width: 400px;text-align: left;'>商品</div>
        <div class="others">买家</div>
        <div class="others">申请退款金额</div>
        <div class="others">价格</div>
        <div class="others">操作</div>
        <div class="others">维权状态/订单状态</div>
    </div>
    <form action="" method="get" class="form-horizontal table-search" role="form"  id="search">
        <div class="page-toolbar">
            <div class="input-group">
                <span class="input-group-btn">
                    {:tpl_form_field_daterange('time', array('starttime'=>date('Y-m-d H:i', $starttime),'endtime'=>date('Y-m-d H:i', $endtime)),true);}
                </span>
                <span class="input-group-select">
                    <select name='searchfield'  class='form-control'   style="width:110px;padding:0 5px;"  >
                        <option value='refundno' {if $searchfield=='refundno'}selected{/if}>业务单号</option>
                        <option value='member' {if $searchfield=='member'}selected{/if}>会员信息</option>
                        <option value='address' {if $searchfield=='address'}selected{/if}>收件人信息</option>
                        <option value='location' {if $searchfield=='location'}selected{/if}>地址信息</option>
                        <option value='expresssn' {if $searchfield=='expresssn'}selected{/if}>快递单号</option>
                        <!-- <option value='goodstitle' {if $searchfield=='goodstitle'}selected{/if}>商品名称</option> -->
                    </select>
                </span>
                <input type="text" class="form-control input-sm"  name="keyword" id="keyword" value="{$keyword}" placeholder="请输入关键词"/>
                <input type="hidden" name="export" id="export" value="0">
                <span class="input-group-btn">
                    <button type="button" data-export="0" class="btn btn-primary btn-submit"> 搜索</button>
                    <button type="button" data-export="1" class="btn btn-success btn-submit">导出</button>
                </span>
            </div>
        </div>
    </form>
    {if !empty(count($list))}
    <div class="row">
        <div class="col-md-12">
            <div  class="">
                <div class="table-header" style='background:#f8f8f8;height: 35px;line-height: 35px;padding: 0 20px'>
                    <div style='border-left:1px solid #f2f2f2;width: 400px;text-align: left;'>商品</div>
                    <div class="others">买家</div>
                    <div class="others">申请退款金额</div>
                    <div class="others">订单价格</div>
                    <div class="others">操作</div>
                    <div class="others">维权状态/订单状态</div>
                </div>
            {foreach name='list' item='item'}
            <div class="table-row"><div style='height:20px;padding:0;border-top:none;'>&nbsp;</div></div>
                <div class="tables">
                    <div class='table-row table-top' style="padding:0  20px;background: #f7f7f7">
                        <div style="text-align: left;color: #8f8e8e;">
                            <span style="font-weight: bold;margin-right: 10px;color: #2d2d31">
                                <span class="shop">{$item['merchname']}</span>{:date('Y-m-d',$item['createtime'])}&nbsp {:date('H:i:s',$item['createtime'])}
                            </span>
                            业务编号:  {$item['refundno']}
                            <label class='label label-danger'>{$r_type[$item['rtype']]}申请</label>
                            {if !empty($item['rstate']) && $item['rstate'] == 4}<label class='label label-default'>客户退回物品</label>{/if}
                        </div>
                        <div style='text-align:right;font-size:12px;' class='aops'>
                        </div>
                    </div>
                    <div class='table-row' style="margin:0  20px">
                        <div class="goods-des" style='width:400px;text-align: left'>
                            {foreach name="$item['goods']" key='k' item='g'}
                            <div style="display: -webkit-box;display: -webkit-flex;display: -ms-flexbox;display: flex;margin: 10px 0">
                                <img src="{$g['thumb']}" style='width:70px;height:70px;border:1px solid #efefef; padding:1px;'onerror="this.src='/public/static/images/nopic.png'">
                                <div style="-webkit-box-flex: 1;-webkit-flex: 1;-ms-flex: 1;flex: 1;margin-left: 10px;text-align: left;display: flex;align-items: center">
                                    <div >
                                        <div class="title">
                                           {if $g['ispresell']==1}
                                           <label class="fui-tag fui-tag-danger">预</label>
                                           {/if}
                                           {$g['title']}<br/>
                                           <span style="color: #999"> {if !empty($g['optiontitle'])}{$g['optiontitle']}{/if}{$g['goodssn']}</span>
                                        </div>
                                        {if $g['seckill_task']}
                                        <div>
                                            <span class="label label-danger">{$g['seckill_task']['tag']}</span>
                                            {if $g['seckill_room']}
                                                <span class="label label-primary">
                                                    {:$g['seckill_room']['tag']?:$g['seckill_room']['title']}
                                                </span>
                                            {/if}
                                        </div>
                                       {/if}
                                    </div>
                                    <span style="float: right;text-align: right;display: inline-block;width:130px;">
                                        ￥{:number_format($g['realprice']/$g['total'],2)}<br/>
                                    x{$g['total']}
                                    </span>
                                </div>
                            </div>
                            {/foreach}
                        </div>
                        <div class="list-inner saler"   style='text-align: center;' >
                            <div>
                                <a href="{:url('admin/member/detail',array('id'=>$item['mid']))}"> {$item['nickname']}</a>
                                <br/>
                                {$item['addressdata']['realname']}<br/>{$item['addressdata']['mobile']}
                            </div>
                        </div>
                        <div class="list-inner paystyle"  style='text-align:center;' >
                            <span style='margin-top:5px;display:block;'>{$item['applyprice']}</span>
                        </div>
                            <a class="list-inner" data-toggle='popover' data-html='true' data-placement='right' data-trigger="hover"
                                    data-content="<table style='width:100%;'>
                                    <tr>
                                        <td  style='border:none;text-align:right;'>商品小计：</td>
                                        <td  style='border:none;text-align:right;;'>￥{:number_format( $item['goodsprice'] ,2)}</td>
                                    </tr>
                                    <tr>
                                        <td  style='border:none;text-align:right;'>运费：</td>
                                        <td  style='border:none;text-align:right;;'>￥{:number_format( $item['olddispatchprice'],2)}</td>
                                    </tr>
                                    {if $item['taskdiscountprice']>0}
                                    <tr>
                                        <td  style='border:none;text-align:right;'>任务活动优惠：</td>
                                        <td  style='border:none;text-align:right;;'>-￥{:number_format( $item['taskdiscountprice'],2)}</td>
                                    </tr>
                                    {/if}
                                    {if $item['lotterydiscountprice']>0}
                                    <tr>
                                        <td  style='border:none;text-align:right;'>游戏活动优惠：</td>
                                        <td  style='border:none;text-align:right;;'>-￥{:number_format( $item['lotterydiscountprice'],2)}</td>
                                    </tr>
                                    {/if}
                                    {if $item['discountprice']>0}
                                    <tr>
                                        <td  style='border:none;text-align:right;'>会员折扣：</td>
                                        <td  style='border:none;text-align:right;;'>-￥{:number_format( $item['discountprice'],2)}</td>
                                    </tr>
                                    {/if}
                                    {if $item['deductprice']>0}
                                    <tr>
                                        <td  style='border:none;text-align:right;'>积分抵扣：</td>
                                        <td  style='border:none;text-align:right;;'>-￥{:number_format( $item['deductprice'],2)}</td>
                                    </tr>
                                    {/if}
                                    {if $item['deductcredit2']>0}
                                    <tr>
                                        <td  style='border:none;text-align:right;'>余额抵扣：</td>
                                        <td  style='border:none;text-align:right;;'>-￥{:number_format( $item['deductcredit2'],2)}</td>
                                    </tr>
                                    {/if}
                                    {if $item['deductenough']>0}
                                    <tr>
                                        <td  style='border:none;text-align:right;'>商城满额立减：</td>
                                        <td  style='border:none;text-align:right;;'>-￥{:number_format( $item['deductenough'],2)}</td>
                                    </tr>
                                    {/if}
                                    {if $item['merchdeductenough']>0}
                                    <tr>
                                        <td  style='border:none;text-align:right;'>商户满额立减：</td>
                                        <td  style='border:none;text-align:right;;'>-￥{:number_format( $item['merchdeductenough'],2)}</td>
                                    </tr>
                                    {/if}
                                    {if $item['couponprice']>0}
                                    <tr>
                                        <td  style='border:none;text-align:right;'>优惠券优惠：</td>
                                        <td  style='border:none;text-align:right;;'>-￥{:number_format( $item['couponprice'],2)}</td>
                                    </tr>
                                    {/if}
                                    {if $item['isdiscountprice']>0}
                                    <tr>
                                        <td  style='border:none;text-align:right;'>促销优惠：</td>
                                        <td  style='border:none;text-align:right;;'>-￥{:number_format( $item['isdiscountprice'],2)}</td>
                                    </tr>
                                    {/if}
                                    {if $item['buyagainprice']>0}
                                    <tr>
                                        <td  style='border:none;text-align:right;'>重复购买优惠：</td>
                                        <td  style='border:none;text-align:right;;'>-￥{:number_format( $item['buyagainprice'],2)}</td>
                                    </tr>
                                    {/if}
                                      {if $item['seckilldiscountprice']>0}
                                    <tr>
                                        <td  style='border:none;text-align:right;'>秒杀优惠：</td>
                                        <td  style='border:none;text-align:right;;'>-￥{:number_format( $item['seckilldiscountprice'],2)}</td>
                                    </tr>
                                    {/if}

                                    {if intval($item['changeprice'])!=0}
                                    <tr>
                                        <td  style='border:none;text-align:right;'>卖家改价：</td>
                                        <td  style='border:none;text-align:right;;'><span style='{if 0<$item['changeprice']}color:green{else}color:red{/if}'>{if 0<$item['changeprice']}+{else}-{/if}￥{:number_format(abs($item['changeprice']),2)}</span></td>
                                    </tr>
                                    {/if}
                                    {if intval($item['changedispatchprice'])!=0}
                                    <tr>
                                        <td  style='border:none;text-align:right;'>卖家改运费：</td>
                                        <td  style='border:none;text-align:right;;'><span style='{if 0<$item['changedispatchprice']}color:green{else}color:red{/if}'>{if 0<$item['changedispatchprice']}+{else}-{/if}￥{:abs($item['changedispatchprice'])}</span></td>
                                    </tr>
                                    {/if}
                                    <tr>
                                        <td style='border:none;text-align:right;'>应收款：</td>
                                        <td  style=`'border:none;text-align:right;color:green;'>￥{:number_format($item['orderprice'],2)}</td>
                                    </tr>

                                </table>"> 
                            <div style='text-align:center'>
                                ￥{:number_format($item['orderprice'],2)}
                                {if $item['dispatchprice']>0}
                                <br/>(含运费:￥{:number_format( $item['dispatchprice'],2)})
                                {/if}
                            </div>
                        </a>
                        <div  class="list-inner"  style='text-align:center' >
                            <a class='op text-primary'  href="{:url('admin/order/detail', array('id' => $item['orderid']))}" >查看订单详情</a>
                            <a class='op text-primary'  href="{:url('admin/order/refund', array('orderid' => $item['orderid'],'refundid' => $item['id']))}" >维权处理</a>
                            {if $item['addressid']!=0 && $item['statusvalue']>=2 && $item['sendtype']==0}
                            <a class='op text-primary'  data-toggle="ajaxModal" href="{:url('admin/utility/express', array('express' => $item['express'],'expresssn' => $item['expresssn']))}"   >物流信息</a>
                            {/if}
                        </div>
                        <div  class='ops list-inner' style='line-height:20px;text-align:center' >
                            <span class='text-{$item['statuscss']}'>{$item['status']}</span><br><span class='text-{$item['orderstatuscss']}'>{$item['orderstatus']}</span>
                        </div>
                    </div>
                    {if !empty($item['remark'])}
                    <div class="table-row"><div  style='background:#fdeeee;color:red;flex: 1;;'>买家备注: {$item['remark']}</div></div>
                    {/if}
            </div>
            {/foreach}
                <div style="padding: 20px;text-align: right" >
                    {$pager}
                </div>
            </div>
        </div>
    </div>
    {else}
    <div class="panel panel-default">
        <div class="panel-body empty-data">暂时没有任何维权信息!</div>
    </div>
    {/if}
</div>

<script>
    //没有选中时间段不能导出
    $(function () {
        $('.btn-submit').click(function () {
            var e = $(this).data('export');
            if(e==1 ){
                if($('#keyword').val() !='' ){
                    $('#export').val(1);
                    $('#search').submit();
                }else if($('#searchtime').val()!=''){
                    $('#export').val(1);
                    $('#search').submit();
                }else{
                    tip.msgbox.err('请先选择时间段!');
                    return;
                }
            }else{
                $('#export').val(0);
                $('#search').submit();
            }
        })
    })
</script>
{include file='_footer'}
